// packageH/circleCommunity/circleSetting/circleSetting.js
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    circleId: 0,
    circleInfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.circleId = options.circleId;
    this.getDetails();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  gotoCirclelssue() {
    wx.navigateTo({
      url: "/packageH/circleCommunity/circleIssue/circlelssue?circleId=" + this.data.circleId,
    });
  },

  gotoCircleChecklist() {
    wx.navigateTo({
      url: "/packageH/circleCommunity/circleChecklist/circleChecklist?circleId=" + this.data.circleId,
    });
  },

  gotoCircleMember() {
    wx.navigateTo({
      url: "/packageH/circleCommunity/circleMember/circleMember?circleId=" + this.data.circleId,
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  getDetails() {
    let urlStr = app.getNetAddresss("plugin.circle.frontend.circle.get-circle");
    app._postNetWork({
      url: urlStr,
      data: { circle_id: this.data.circleId },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);
        this.setData({
          circleInfo: res.data,
        });
        console.log(res);
      },
    });
  },

  bindSwitchChange(evt) {
    console.log(evt);
    let json = { circle_id: this.data.circleId, authority_type: {} };
    json.authority_type = evt.currentTarget.dataset.type;
    let urlStr = app.getNetAddresss("plugin.circle.frontend.circle.set-circle-authority");
    app._postNetWork({
      url: urlStr,
      data: json,
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);
      },
    });
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareTimeline(){},
  onShareAppMessage: function () {},
});
